﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ReaderTypeManage : System.Web.UI.Page
{
    public string orderOftype;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataSource1.SelectCommand = "select ReaderType as 编号,TypeName as 类型名, MaxLend as 最大借阅数量 from Reader_type order by ReaderType  ";
        /// SqlDataSource1.SelectParameters["name"].DefaultValue = Session["userName"].ToString();
        /// 


    }
    protected void delete_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in mybookdata.Rows)
        {
            Control ctrl = row.FindControl("CheckBox");

            if ((ctrl as CheckBox).Checked)
            {
                TableCellCollection cell = row.Cells;
                string typeid = cell[1].Text;
                SQL sql = new SQL();
                sql.EXQSQL("delete from Reader_type where Readertype='" + typeid + "'");
            }
        }
        Response.Write("<script language=javascript>alert('删除成功');window.location = 'ReaderTypeManage.aspx';</script>");
    }

    protected void change_Click(object sender, EventArgs e)
    {
        try
        {
            int i = Convert.ToInt32(TextBox1.Text);
            SQL sql = new SQL();
            sql.EXQSQL("update book_type set Reader_Type='" + TextBox1.Text + "' ,MaxLend='" + TextBox2.Text + "' where  booktype='" + TextBox1.Text + "'");
            Response.Write("<script language=javascript>alert('修改成功');window.location = 'ReaderTypeManage.aspx';</script>");
        }
        catch (System.Exception ex)
        {
            Label1.Text = "警告：您输入有误";
        }
    }

    protected void chaxun_Click(object sender, EventArgs e)
    {

    }
    protected void sureAdd_Click(object sender, EventArgs e)
    {
        try
        {
            string i = TypeID.Text;
            SQL sql = new SQL();
            sql.EXQSQL("insert into reader_type values('4','" + i + "','" + Typename.Text + "') ");
            Response.Write("<script language=javascript>alert('增加成功');window.location = 'ReaderTypeManage.aspx';</script>");
        }
        catch (System.Exception ex)
        {
            Response.Write("<script language=javascript>alert('ERROR！');window.location = 'ReaderTypeManage.aspx';</script>");
            Label1.Text = "警告：您输入的类别有误";
        }



    }
}